<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>网上银行用户登录</title>
    <!--1.引入bootstrap样式框架；-->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">

    <!--2.引入angularJS分页样式的框架；-->
    <link rel="stylesheet" href="angularjs/pagination.css">

    <link rel="stylesheet" href="layer/theme/default/layer.css">

    <!--3.引入bootstrap中的Jquery框架；-->
    <script src="bootstrap/js/jquery.min.js"></script>
    <!--4.引入bootstrap中的Js框架；-->
    <script src="bootstrap/js/bootstrap.min.js"></script>

    <script src="//cdn.bootcss.com/angular.js/1.5.8/angular.min.js"></script>
    <script src="//cdn.bootcss.com/angular.js/1.5.8/angular-route.js"></script>

    <!--<script src="//unpkg.com/angular-ui-router@0.4.2/release/angular-ui-router.js"></script>-->
    <!--6.引入AngularJS分布的JS框架-->
    <script src="angularjs/pagination.js"></script>

    <script src="layer/layer.js"></script>


    <style type="text/css">
        .el-register-form {
            width: 600px;
            margin-left: auto;
            margin-right: auto;
            margin-top: 20px;
        }

        .el-register-form .form-control {
            width: 220px;
            display: inline;
        }
    </style>

</head>
<body>
<div>
    <ol class="breadcrumb" style="margin-top: 0px;margin-bottom: 0;">
        <li><a >Home</a></li>
        <li><a >银行</a></li>
        <li><a href="index.html">返回首页</a></li>
    </ol>
</div>
<div ng-cloak ng-app="myApp" style="margin-top: 60px;">
    <form name="myForm" ng-controller="UserController" class="container form-horizontal">
        <h1 style="margin-left: 330px;">网上银行用户登录</h1>
        <p>&nbsp;</p>
        <div class="form-group has-feedback" ng-class="{'has-error':myForm.ukPhone.$dirty && myForm.ukPhone.$invalid}">
            <label class="col-sm-4 control-label">电话</label>
            <div class="col-sm-4">
                <input type="text" autocomplete="off" name="ukPhone" ng-required="true" required autofocus
                       ng-minlength="11" ng-maxlength="11" ng-model="ukPhone" class="form-control"
                       placeholder="电话号码">
                <div ng-show="myForm.ukPhone.$dirty && myForm.ukPhone.$error.maxlength"
                     class="alert alert-danger help-block">
                    电话长度不能超过11位
                </div>
                <div ng-show="myForm.ukPhone.$dirty && myForm.ukPhone.$error.minlength"
                     class="alert alert-danger help-block">
                    电话格式错误
                </div>

            </div>
        </div>
        <div class="form-group" ng-class="{'has-error':myForm.userPassword.$dirty && myForm.userPassword.$invalid}">
            <label class="col-sm-4 control-label">密 码</label>
            <div class="col-sm-4">
                <input type="password" autocomplete="off" name="userPassword" ng-required="true" ng-minlength="6"
                       ng-maxlength="10" ng-model="userPassword" class="form-control" placeholder="password">
                <div ng-show="myForm.userPassword.$dirty && myForm.userPassword.$error.maxlength"
                     class="alert alert-danger help-block">
                    密码长度不能超过10位
                </div>
                <div ng-show="myForm.userPassword.$dirty && myForm.userPassword.$error.minlength"
                     class="alert alert-danger help-block">
                    密码长度不能少于6位
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-4 col-sm-4">
                <button type="submit" class="btn btn-success col-sm-6" ng-click="userlogin()">登录</button>
                <button type="submit" class="btn btn-info col-sm-6" ng-click="reset()">注册</button>
            </div>
        </div>
    </form>
</div>
<script>
    layerindex=-1;
    var myApp = angular.module('myApp', [])
    myApp.controller('UserController', function ($scope, $http) {
        $scope.userlogin = function () {
            $http.get("http://127.0.0.1:12000/user/tourist/login?ukPhone="+$scope.ukPhone+"&userPassword="+$scope.userPassword).success(function (data) {
                //console.info(data.msg);
                console.log(data);
                if (data.code == 200) {
                    window.sessionStorage.setItem("ukPhone",$scope.ukPhone);

                    for (var key in data.data) {
                        window.sessionStorage.setItem("token",key)
                        //console.log(data.data[key])
                        // window.sessionStorage.setItem("user",data.data[key])
                        window.sessionStorage.setItem("uid",data.data[key].pkUserId);
                        window.sessionStorage.setItem("uname",data.data[key].userName);

                        console.log("uname"+data.data[key].userName)
                    }

                    layer.close(layerindex);
                    layer.msg(data.msg,{icon:6,title:"系统提示："});
                    window.location.href='/index.html';
                }else {
                    alert(data.msg);
                }
            })
        };

        $scope.reset = function() {
            window.location.href='register.html';
        }
    });
</script>
</body>
</html>